//
//  Menu.m
//  Finder
//
//  Created by cdm on 11-3-21.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "Menu.h"

@implementation Menu

@synthesize name;
@synthesize isShow;

+ (Menu *)menuFormDict:(NSDictionary *)dict
{
    Menu *menu = [[[Menu alloc] init] autorelease];
    
    NSString *name = [dict objectForKey:@"Name"];
    BOOL isShow = [[dict objectForKey:@"IsShow"] boolValue];
    
    menu.name = name;
    menu.isShow = isShow;
    
    return menu;
}

+ (NSMutableArray *)menusFromPlist:(NSString *)plistName
{
    NSMutableArray *menus = [[[NSMutableArray alloc] init] autorelease];
   
    NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:nil inDirectory:nil forLocalization:[AppLanguage getLanguageAsString]];
    //NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:nil];
    NSArray *dicts = [[NSArray alloc] initWithContentsOfFile:path];

    for (NSDictionary *dict in dicts) {
        Menu *menu = [self menuFormDict:dict];
        [menus addObject:menu];
    }
        
    [dicts release];
    
    return menus;
}

@end
